package com.bwie.user.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bwie.user.entity.RolesAndPermissionsEntity;
import com.bwie.user.service.RolesAndPermissionsService;
import com.bwie.common.utils.PageUtils;
import com.bwie.common.utils.R;



/**
 * 
 *
 * @author HouDing
 * @email 1398853436@qq.com
 * @date 2022-03-23 21:38:29
 */
@RestController
@RequestMapping("user/rolesandpermissions")
public class RolesAndPermissionsController {
    @Autowired
    private RolesAndPermissionsService rolesAndPermissionsService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = rolesAndPermissionsService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{rpId}")
    public R info(@PathVariable("rpId") Integer rpId){
		RolesAndPermissionsEntity rolesAndPermissions = rolesAndPermissionsService.getById(rpId);

        return R.ok().put("rolesAndPermissions", rolesAndPermissions);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody RolesAndPermissionsEntity rolesAndPermissions){
		rolesAndPermissionsService.save(rolesAndPermissions);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody RolesAndPermissionsEntity rolesAndPermissions){
		rolesAndPermissionsService.updateById(rolesAndPermissions);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] rpIds){
		rolesAndPermissionsService.removeByIds(Arrays.asList(rpIds));

        return R.ok();
    }

}
